//
//  DriverAddInPutCell.m
//  LogisticsSupplier
//
//  Created by 吕晶 on 2020/8/6.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "DriverAddInPutCell.h"
#import "LJCustomTextView.h"

@interface DriverAddInPutCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *remarkTitleLab;
@property (nonatomic, strong) UILabel *remarkCountLab;
@property (nonatomic, strong) LJCustomTextView *remarkTextView;

@end

@implementation DriverAddInPutCell

+ (instancetype)DriverAddInPutCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"DriverAddInPutCell";
    DriverAddInPutCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[DriverAddInPutCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = Color_backgroundColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, ScreenW - 30, 120)];
        self.bgView.backgroundColor = HexColor(0xffffff);
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius = 6;
        [self.contentView addSubview:self.bgView];
        
        self.remarkTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, [FactoryMethod sizeWithText:@"备注" font:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(0, 0)].width, [FactoryMethod sizeWithText:@"备注" font:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(0, 0)].height)];
        self.remarkTitleLab.textColor = HexColor(0x2B2C44);
        self.remarkTitleLab.font = [UIFont systemFontOfSize:14];
        self.remarkTitleLab.text = @"备注";
        [self.bgView addSubview:self.remarkTitleLab];
        
        self.remarkCountLab = [[UILabel alloc] initWithFrame:CGRectMake(self.remarkTitleLab.nim_right + 10, self.remarkTitleLab.nim_top, 100, self.remarkTitleLab.nim_height)];
        self.remarkCountLab.textColor = HexColor(0xBDBED9);
        self.remarkCountLab.font = [UIFont systemFontOfSize:12];
        self.remarkCountLab.text = @"0/255";
        [self.bgView addSubview:self.remarkCountLab];
        
        self.remarkTextView = [[LJCustomTextView alloc] initWithFrame:CGRectMake(10, self.remarkTitleLab.nim_bottom + 10, self.bgView.nim_width - 20, self.bgView.nim_height - 10 - (self.remarkTitleLab.nim_bottom + 10))];
        self.remarkTextView.placeholder = @"请输入";
        self.remarkTextView.textColor = HexColor(0x2B2C44);
        self.remarkTextView.font = [UIFont systemFontOfSize:14];
        self.remarkTextView.textLength = 255;
        __weak_self;
        self.remarkTextView.countBlock = ^(NSString * _Nonnull str) {
            weakself.remarkCountLab.text = str;
            if (weakself.remarkBlock) {
                weakself.remarkBlock(weakself.remarkTextView.text);
            }
        };
        [self.bgView addSubview:self.remarkTextView];
        
        self.height = self.bgView.nim_bottom;
    }
    return self;
}

-(void)setContentText:(NSString *)contentText {
    _contentText = contentText;
    self.remarkTextView.customText = contentText.length?contentText:@"";
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
